var path = "/OA";

$(function(){
	

	$("#btn").click(function(){
		$.ajax({
			url :path + "/manager/addManager",
			data:{"username":$("#username").val() , "password" : $("#password").val() , "realname" : $("#realname").val() , "type":$("#type").val()},
			dataType:"json",
			error:function(){
				alert("系统错误");
			},
			success:function(data){
				console.log(data);
				if(data.success){
					layer.alert(data.message,'信息提示',function(){
						location.reload();
					});
				}else{
					layer.alert(data.message);
					console.log(data);
				}
			}
		});
	});
	
});

/*function returnManager(managerid){
	console.log(managerid);
	$.ajax({
		url:path +"/manager/getManager",
		data:{"managerid":managerid},
		dataType:"json",
		error:function(){
			alert("系统错误");
		},
		success:function(data){
			console.log(data);
			if(data.success){
				$("#eusername").val(data.object.username);
				$("#erealname").val(data.object.realname);
				$("#etype").val(data.object.type);
				$("#epassword").val(data.object.password);
				$("#managerid").val(data.object.id)
			}
		}
	});
}

$("#updateBtn").click(function(){
	$.ajax({
		url :path + "/manager/updateManager",
		type:"post",
		data:{"username":$("#eusername").val() , "id" : $("#managerid").val() , "realname" : $("#erealname").val() , "type":$("#etype").val(),"password": $("#epassword").val() },
		dataType:"json",
		error:function(){
			alert("系统错误");
		},
		success:function(data){
			console.log(data);
			if(data.success){
				layer.alert(data.message,'信息提示',function(){
					location.reload();
				});
			}else{
				layer.alert(data.message);
				console.log(data);
			}
		}
	});
})

function sureDelete(id){
	layer.confirm("是否删除该管理员?" ,{
		btn:['是','否']
	},function(){
		$.ajax({
			url : path +"/manager/deleteManager",
			data:{"id" : id},
			dataType:"json",
			error:function(){
				layer.alert("系统错误");
			},
			success:function(data){
				if(data.success){
					layer.alert(data.message,'信息提示',function(){
						location.reload();
					});
				}else{
					layer.alert(data.message);
					console.log(data);
				}
			}
		});
	}
	)
}
*/